# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=unicode-character-database
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=15.0.0
pkgrel=2
pkgdesc="Unicode Character Database (mingw-w64)"
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
license=(BSD)
url="https://www.unicode.org/"
source=("UCD-${pkgver}.zip::https://www.unicode.org/Public/zipped/${pkgver}/UCD.zip"
        "Unihan-${pkgver}.zip::https://www.unicode.org/Public/zipped/${pkgver}/Unihan.zip"
        'LICENSE::https://www.unicode.org/license.txt')
noextract=({UCD,Unihan}-$pkgver.zip)
sha512sums=('442a99694fccf0d1ff6f6236bec2cff7408eef4d9dba575ba4f5dc45cebf4d2b1b30334ef8a843887a0f410b24e0f79f7f30f06a195659def998875981604a6a'
            'd9cf39adebe83ed0fd8d473cf057b8aa8b2362019d9f7ee7afc041501b1bbbe4d13050350ac40ce4a020cd1d64d52548fe262c3b2893934a032e1de8075e964c'
            '302b06647f30fa8bd29ed212ba7a46e7415db8f4c45f7994fe298c3c752ac1e91f1554e75112ca3e89f5f4134cb74f52d429274111898970ab2121565a5699d9')

package() {
  for _f in UCD Unihan; do
    install -Dm644 ${_f}-${pkgver}.zip "${pkgdir}${MINGW_PREFIX}/share/unicode/${_f}.zip"
    bsdtar -C "${pkgdir}${MINGW_PREFIX}/share/unicode" -x --no-same-owner --no-same-permissions -f $_f-$pkgver.zip
  done

  #  ln -s unicode "$pkgdir${MINGW_PREFIX}/share/${_realname}"
  # FS#49938: A bunch of compatibility symlinks
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/unicode/ucd
  cp -r * "${pkgdir}${MINGW_PREFIX}/share/unicode/ucd/"
  for _f in ${_realname} unicode-data unidata; do
    cp -r ${pkgdir}${MINGW_PREFIX}/share/unicode "${pkgdir}${MINGW_PREFIX}/share/${_f}/"
  done

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
